package com.yanq.liancar.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yanq.liancar.R;
import com.yanq.liancar.bean.ServiceOrderBean;

import java.util.List;

public class MyServiceOrderAdapter extends BaseQuickAdapter<ServiceOrderBean.DataBean, BaseViewHolder> {
    public MyServiceOrderAdapter(int layoutResId, @Nullable List<ServiceOrderBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ServiceOrderBean.DataBean item) {
        helper.setText(R.id.shop_title, item.getOrder().getServiceName())
                .setText(R.id.Order_time, item.getOrder().getPayDate())
                .setText(R.id.Term_of_validity, item.getOrder().getValiDate())
                .setText(R.id.tv_Total, "¥" + item.getOrder().getAllPrice())
                .addOnClickListener(R.id.tv_evaluate);
        TextView tv_wait_evaluate = helper.getView(R.id.tv_wait_evaluate);  //待评价
        ImageView img_logo = helper.getView(R.id.img_logo);
        TextView tv_evaluate = helper.getView(R.id.tv_evaluate);       //评价

        if (item.getOrder().getOrderStatus() == 1) {
            tv_wait_evaluate.setText("待支付");
            tv_evaluate.setVisibility(View.VISIBLE);
            tv_evaluate.setText("去支付");
        } else if (item.getOrder().getOrderStatus() == 2) {
            tv_wait_evaluate.setText("待接单");
            tv_evaluate.setVisibility(View.GONE);
        } else if (item.getOrder().getOrderStatus() == 3) {
                tv_wait_evaluate.setText("拒接单");
                tv_evaluate.setVisibility(View.VISIBLE);
                tv_evaluate.setText("查看原因");
        } else if (item.getOrder().getOrderStatus() == 4) {
            tv_wait_evaluate.setText("待完成");
            tv_evaluate.setVisibility(View.GONE);
        } else if (item.getOrder().getOrderStatus() == 5) {
            tv_wait_evaluate.setText("已完成");
            tv_evaluate.setVisibility(View.VISIBLE);
            tv_evaluate.setText("评价");
        } else {
            tv_wait_evaluate.setText("已评价");
            tv_evaluate.setVisibility(View.GONE);
        }
        RequestOptions options=new RequestOptions();
        options.placeholder(R.mipmap.item_fuwu);
        Glide.with(mContext).load(item.getPage()).apply(options).into(img_logo);
    }
}
